package com.teamcenter.rac.massupdate.model;

import java.util.List;

import org.apache.log4j.Logger;
import org.eclipse.ui.views.properties.IPropertyDescriptor;
import org.eclipse.ui.views.properties.IPropertySource;
import org.eclipse.ui.views.properties.PropertyDescriptor;

import com.teamcenter.rac.kernel.TCComponent;
import com.teamcenter.rac.kernel.TCException;
import com.teamcenter.rac.massupdate.providers.PropertySourceLabelProvider;
import com.teamcenter.rac.massupdate.utils.SourceHelper;
@SuppressWarnings({"unused","rawtypes","unchecked"})
public class MarkupChangeModel
  extends AbstractWrappedPropertySource
  implements ISubmitToWorkflowRow
{
  public static final String MARKUP_CHANGE_IMPACTED_PART_PROP = "fnd0modified_object";
  public static final String MARKUP_CHANGE_NOTE_PROP = "fnd0note";
  public static final String MARKUP_CHANGE_OPERATION_TYPE_PROP = "fnd0markup_type";
  public static final String[] MARKUP_CHANGE_PROPS = { "fnd0modified_object", "fnd0context", "fnd0markup_type", "fnd0input_object", "fnd0status", "fnd0note" };
  public static final String MARKUP_CHANGE_REPLACEMENT_PART_PROP = "fnd0input_object";
  public static final String MARKUP_CHANGE_STATUS_PROP = "fnd0status";
  public static final String MARKUP_CHANGE_TARGET_PART_PROP = "fnd0context";
  public static final String MARKUP_CHANGE_TYPE = "Fnd0MarkupChange";
  public static final String[] MARKUP_CHANGE_PROP_NAMES = { "Fnd0MarkupChange.fnd0modified_object", "Fnd0MarkupChange.fnd0context", "Fnd0MarkupChange.fnd0markup_type", "Fnd0MarkupChange.fnd0input_object", "Fnd0MarkupChange.fnd0status", "Fnd0MarkupChange.fnd0note" };
  private static final int NUM_LOCAL_PROP = 2;
  private static final String PROP_MARKUP_CHANGE = "markupChange";
  private static final String PROP_IMPACTED_COMPONENT = "impactedComponent";
  
  public MarkupChangeModel()
  {
    super(2);
    this.m_localPropNames.add("markupChange");
    this.m_localPropNames.add("selected");
    this.m_localPropNames.add("impactedComponent");
  }
  
  public MarkupChangeModel(IPropertySource paramIPropertySource)
  {
    this();
    setMarkupChange(paramIPropertySource);
    getComponent();
  }
  
  public IPropertySource getMarkupChange()
  {
    return (IPropertySource)getPropertyValue("markupChange");
  }
  
  public IPropertyDescriptor[] getPropertyDescriptors()
  {
    if (this.m_propertyDescriptors == null)
    {
      List localList = getWrappedPropertyDescriptors(2);
      PropertyDescriptor localPropertyDescriptor = new PropertyDescriptor("markupChange", Messages.MarkupChangeModel_Prop_MarkupChange);
      localPropertyDescriptor.setLabelProvider(new PropertySourceLabelProvider("markupChange"));
      localList.add(localPropertyDescriptor);
      this.m_propertyDescriptors = ((IPropertyDescriptor[])localList.toArray(new IPropertyDescriptor[localList.size()]));
    }
    return this.m_propertyDescriptors;
  }
  
  public void setMarkupChange(IPropertySource paramIPropertySource)
  {
    setWrappedPropertySource(paramIPropertySource);
    updateAndAnnounceProperty("markupChange", paramIPropertySource);
  }
  
  public void setSelected(boolean paramBoolean)
  {
    setPropertyValue("selected", Boolean.valueOf(paramBoolean));
  }
  
  public boolean isSelected()
  {
    return getPropertyValueAsBoolean("selected");
  }
  
  public Object getIdentifier()
  {
    return getPropertyValue("UID");
  }
  
  public Object getData()
  {
    return this;
  }
  
  public Object getValue(String paramString)
  {
    if ("fnd0status".equals(paramString)) {
      return MarkupChangeStatus.fromIntToString(Integer.parseInt((String)getPropertyValue(paramString)));
    }
    if (("owning_group".equals(paramString)) || ("owning_user".equals(paramString)) || ("release_status_list".equals(paramString))) {
      try
      {
        return getComponent().getProperty(paramString);
      }
      catch (TCException localTCException)
      {
        Logger.getLogger(MarkupChangeModel.class).error(localTCException.getLocalizedMessage(), localTCException);
        return null;
      }
    }
    return getPropertyValue(paramString);
  }
  
  public void setValue(String paramString, Object paramObject)
  {
    setPropertyValue(paramString, paramObject);
  }
  
  public TCComponent getComponent()
  {
    TCComponent localTCComponent1 = (TCComponent)getPropertyValue("impactedComponent");
    if (localTCComponent1 == null)
    {
      TCComponent localTCComponent2 = SourceHelper.getAssociatedComponent(getMarkupChange(), getTCSession());
      if (localTCComponent2 != null) {
        try
        {
          localTCComponent1 = localTCComponent2.getReferenceProperty("fnd0modified_object");
        }
        catch (TCException localTCException)
        {
          Logger.getLogger(MarkupChangeModel.class).error(localTCException.getLocalizedMessage(), localTCException);
        }
      }
      setPropertyValue("impactedComponent", localTCComponent1);
    }
    return localTCComponent1;
  }
  
  public static enum MarkupChangeStatus
  {
    WORKING,  OBSOLETE,  APPLIED,  FAILED;
    
    public static String fromIntToString(int paramInt)
    {
      switch (paramInt)
      {
      case 0: 
        return Messages.MarkupChangeModel_Status_Working;
      case 1: 
        return Messages.MarkupChangeModel_Status_Obsolete;
      case 2: 
        return Messages.MarkupChangeModel_Status_Applied;
      case 3: 
        return Messages.MarkupChangeModel_Status_Failed;
      }
      return String.valueOf(paramInt);
    }
  }
}


/* Location:              D:\下载\Fw_ 金卡反编译需求\com.teamcenter.rac.massupdate_11000.2.0.jar!\com\teamcenter\rac\massupdate\model\MarkupChangeModel.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */